gdk_quartz_drawable_release_context (drawable, context);
}
+static inline void
+gdk_quartz_fix_cap_not_last_line (GdkGCQuartz *private,
+ gint x1,
+ gint y1,
+ gint x2,
+ gint y2,
+ gint *xfix,
+ gint *yfix)
+{
+ *xfix = 0;
+ *yfix = 0;
+
+ if (private->cap_style == GDK_CAP_NOT_LAST && private->line_width == 0)
+ {
+ /* fix only vertical and horizontal lines for now */
+
+ if (y1 == y2 && x1 != x2)
+ {
+ *xfix = (x1 < x2) ? -1 : 1;
+ }
+ else if (x1 == x2 && y1 != y2)
+ {
+ *yfix = (y1 < y2) ? -1 : 1;
+ }
+ }
+}
+
static void
gdk_quartz_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
gint nsegs)
{
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
+ GdkGCQuartz *private;
int i;
if (!context)
return;
+ private = GDK_GC_QUARTZ (gc);
+
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
GDK_QUARTZ_CONTEXT_STROKE);
for (i = 0; i < nsegs; i++)
{
+ gint xfix, yfix;
+
+ gdk_quartz_fix_cap_not_last_line (private,
+ segs[i].x1, segs[i].y1,
+ segs[i].x2, segs[i].y2,
+ &xfix, &yfix);
+
CGContextMoveToPoint (context, segs[i].x1 + 0.5, segs[i].y1 + 0.5);
- CGContextAddLineToPoint (context, segs[i].x2 + 0.5, segs[i].y2 + 0.5);
+ CGContextAddLineToPoint (context, segs[i].x2 + 0.5 + xfix, segs[i].y2 + 0.5 + yfix);
}
CGContextStrokePath (context);
gint npoints)
{
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
- int i;
+ GdkGCQuartz *private;
+ gint xfix, yfix;
+ gint i;
if (!context)
return;
+ private = GDK_GC_QUARTZ (gc);
+
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
- GDK_QUARTZ_CONTEXT_STROKE);
+ GDK_QUARTZ_CONTEXT_STROKE);
CGContextMoveToPoint (context, points[0].x + 0.5, points[0].y + 0.5);
- for (i = 1; i < npoints; i++)
+ for (i = 1; i < npoints - 1; i++)
CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
+ gdk_quartz_fix_cap_not_last_line (private,
+ points[npoints - 2].x, points[npoints - 2].y,
+ points[npoints - 1].x, points[npoints - 1].y,
+ &xfix, &yfix);
+
+ CGContextAddLineToPoint (context,
+ points[npoints - 1].x + 0.5 + xfix,
+ points[npoints - 1].y + 0.5 + yfix);
+
CGContextStrokePath (context);
gdk_quartz_drawable_release_context (drawable, context);